/****** Object:  Table [dbo].[SYS_ATTACH]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_ATTACH]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_ATTACH](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_DESKTOP]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_DESKTOP](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[TITLE] [nvarchar](200) NULL,
	[KEY_VAL] [nvarchar](100) NULL,
	[TYPE] [varchar](100) NULL,
	[LAYOUT_TYPE] [varchar](100) NULL,
	[LAYOUT_VAL] [varchar](2000) NULL,
	[LEVEL_VAL] [numeric](2, 0) NULL,
	[DISPLAY_NUM] [numeric](5, 0) NULL,
	[MODULE_URL] [varchar](2000) NULL,
	[DATA_URL] [varchar](2000) NULL,
	[SOURCE_TYPE] [varchar](100) NULL,
	[SOURCE] [nvarchar](max) NULL,
	[HEIGHT] [numeric](5, 0) NULL,
	[FONT_NUM] [numeric](5, 0) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[PARENT_ID] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_DESKTOP] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_COMMON_TYPE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_COMMON_TYPE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_COMMON_TYPE](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[NAME] [nvarchar](500) NULL,
	[PID] [numeric](38, 0) NULL,
	[TYPE_VAL] [varchar](200) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_COMMON_TYPE] PRIMARY KEY CLUSTERED
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_ROLE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_ROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_ROLE](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[ORGANIZATION_ID] [numeric](38, 0) NULL,
	[ROLE_NAME] [nvarchar](100) NOT NULL,
	[ROLE_DESC] [nvarchar](500) NULL,
	[ROLE_STATUS] [varchar](1) NULL,
	[CREATE_TIME] [datetime] NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_ROLE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_RESOURCE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_RESOURCE](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[RESOURCE_NAME] [nvarchar](100) NOT NULL,
	[RESOURCE_SIGN] [nvarchar](100) NOT NULL,
	[RESOURCE_TYPE] [varchar](2) NOT NULL,
	[PARENT_ID] [numeric](38, 0) NULL,
	[RESOURCE_ICON] [nvarchar](50) NULL,
	[OPEN_TYPE] [varchar](1) NULL,
	[RESOURCE_STATUS] [varchar](1) NULL,
	[RESOURCE_NO] [numeric](10, 0) NULL,
	[RESOURCE_URL] [nvarchar](500) NULL,
	[RESOURCE_LEVEL] [varchar](2) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[REMARK] [nvarchar](500) NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[LOG_RULE] [nvarchar](1000) NULL,
 CONSTRAINT [PK_SYS_RESOURCE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_PROCESS_INFO]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_PROCESS_INFO]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_PROCESS_INFO](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[PROCESS_INSTANCE_ID] [varchar](100) NULL,
	[EXECUTION_ID] [varchar](100) NULL,
	[USER_ID] [numeric](38, 0) NULL,
	[DEAL_NAME] [nvarchar](100) NULL,
	[IS_APPROVE] [varchar](50) NULL,
	[REASON] [nvarchar](2000) NULL,
	[DEAL_TIME] [datetime] NULL,
	[BUSINESS_ID] [numeric](38, 0) NULL,
	[BUSINESS_NAME] [varchar](200) NULL,
	[TASK_ID] [varchar](100) NULL,
	[TASK_NAME] [nvarchar](1000) NULL,
	[ACTIVITI_ID] [varchar](200) NULL,
	[COUNT_VAL] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_PROCESS_INFO] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_ORGANIZATION]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_ORGANIZATION]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_ORGANIZATION](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[PARENT_ID] [numeric](38, 0) NULL,
	[ORGANIZATION_NAME] [nvarchar](100) NOT NULL,
	[ORGANIZATION_NO] [numeric](10, 0) NULL,
	[ORGANIZATION_DESC] [nvarchar](500) NULL,
	[CREATE_TIME] [datetime] NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[ORGANIZATION_CODE] [nvarchar](2000) NULL,
	[PARENT_ORGANIZATION_CODE] [nvarchar](2000) NULL,
 CONSTRAINT [PK_SYS_ORGANIZATION] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_NOTICE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_NOTICE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_NOTICE](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[TITLE] [nvarchar](200) NULL,
	[KEY_VAL] [nvarchar](1000) NULL,
	[CONTENT_VAL] [nvarchar](max) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[STATUS] [varchar](50) NULL,
	[TYPE] [numeric](38, 0) NULL,
	[ATM_ID] [numeric](38, 0) NULL,
	[STYLE] [nvarchar](50) NULL,
	[LEVEL_VAL] [nvarchar](50) NULL,
	[MODULE_KEY] [varchar](200) NULL,
    [MODULE_DATA_ID] [varchar](100) NULL,
 CONSTRAINT [PK_SYS_NOTICE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_NEWS]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_NEWS]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_NEWS](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[TITLE] [nvarchar](200) NULL,
	[KEY_VAL] [nvarchar](1000) NULL,
	[CONTENT_VAL] [nvarchar](max) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[STATUS] [varchar](50) NULL,
	[TYPE] [numeric](38, 0) NULL,
	[ATM_ID] [numeric](38, 0) NULL,
	[CLICK_COUNT] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_NEWS] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_LOG]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_LOG]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_LOG](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[OPERATION_URL] [nvarchar](500) NULL,
	[OPERATION_METHOD] [nvarchar](100) NULL,
	[OPERATION_NAME] [nvarchar](100) NULL,
	[OPERATION_DESC] [nvarchar](1000) NULL,
	[OPERATION_TIME] [datetime] NOT NULL,
	[OPERATION_IP] [nvarchar](100) NULL,
	[OPERATION_MACHINE_NAME] [nvarchar](100) NULL,
	[REAMRK] [nvarchar](500) NULL,
	[LOGIN_NAME] [nvarchar](50) NULL,
	[REAL_NAME] [nvarchar](50) NULL,
	[ORG_NAME] [nvarchar](100) NULL,
 CONSTRAINT [PK_SYS_LOG] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_EXCEPTION_LOG]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_EXCEPTION_LOG]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_EXCEPTION_LOG](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[THREAD_NAME] [nvarchar](1000) NULL,
	[LOGGER_NAME] [nvarchar](1000) NULL,
	[LEVEL] [nvarchar](100) NULL,
	[MESSAGE] [nvarchar](max) NULL,
	[LOG_TIME] [datetime] NOT NULL,
	[METHOD_NAME] [nvarchar](4000) NULL,
	[CLASS_NAME] [nvarchar](4000) NULL,
 CONSTRAINT [PK_SYS_EXCEPTION_LOG] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_DICTIONARY_TYPE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_DICTIONARY_TYPE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_DICTIONARY_TYPE](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[DICT_TYPE_NAME] [nvarchar](100) NOT NULL,
	[DICT_TYPE_DESC] [nvarchar](100) NULL,
	[TYPE] [varchar](1) NOT NULL,
	[DICT_TYPE_KEY] [nvarchar](100) NULL,
	[CREATE_TIME] [datetime] NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_DICTIONARY_TYPE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_DICTIONARY]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_DICTIONARY]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_DICTIONARY](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[DICT_TYPE_ID] [numeric](38, 0) NOT NULL,
	[DICT_NAME] [nvarchar](100) NOT NULL,
	[DICT_VALUE] [nvarchar](100) NOT NULL,
	[STATUS] [varchar](1) NULL,
	[DICT_DESC] [nvarchar](500) NULL,
	[DICT_LOCALE] [nvarchar](50) NULL,
	[CREATE_TIME] [datetime] NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
 CONSTRAINT [PK_SYS_DICTIONARY] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_RESOURCE_TO_ROLE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_TO_ROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_RESOURCE_TO_ROLE](
	[ROLE_ID] [numeric](38, 0) NOT NULL,
	[RESOURCE_ID] [numeric](38, 0) NOT NULL
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_RESOURCE_LOCALE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_LOCALE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_RESOURCE_LOCALE](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[RESOURCE_ID] [numeric](38, 0) NULL,
	[RESOURCE_NAME] [nvarchar](100) NULL,
	[RESOURCE_LOCALE] [nvarchar](50) NULL,
 CONSTRAINT [PK_SYS_RESOURCE_LOCALE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_ATTACH_DETAIL]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_ATTACH_DETAIL]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_ATTACH_DETAIL](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[FILE_NAME] [nvarchar](500) NULL,
	[FILE_SIZE] [numeric](38, 0) NOT NULL,
	[FILE_PATH] [varchar](1000) NULL,
	[ATTACH_ID] [numeric](38, 0) NOT NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_USER]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_USER]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_USER](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[LOGIN_NAME] [nvarchar](50) NOT NULL,
	[PASSWORD] [nvarchar](50) NOT NULL,
	[ORGANIZATION_ID] [numeric](38, 0) NULL,
	[MANAGER_ID] [numeric](38, 0) NULL,
	[REMOTE_LOGIN] [varchar](1) NULL,
	[REAL_NAME] [nvarchar](50) NOT NULL,
	[SEX] [varchar](1) NULL,
	[PHONE] [nvarchar](50) NULL,
	[MOBILE_PHONE] [nvarchar](50) NULL,
	[FAX] [nvarchar](50) NULL,
	[EMAIL] [nvarchar](100) NULL,
	[ADDRESS] [nvarchar](500) NULL,
	[STATUS] [varchar](1) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[ALLOWERROR] [numeric](3, 0) NULL,
	[ALLEDYERROR] [numeric](3, 0) NULL,
	[REMARK] [nvarchar](1000) NULL,
	[IS_SUPER_ADMIN] [varchar](1) NULL,
	[EMPLOYEE_ID] [nvarchar](100) NULL,
	[NICKNAME] [nvarchar](100) NULL,
 CONSTRAINT [PK_SYS_USER] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_DESKTOP_TO_ROLE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_ROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_DESKTOP_TO_ROLE](
	[DESKTOP_ID] [numeric](38, 0) NOT NULL,
	[ROLE_ID] [numeric](38, 0) NOT NULL
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_USER_TO_ROLE]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_USER_TO_ROLE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_USER_TO_ROLE](
	[USER_ID] [numeric](38, 0) NOT NULL,
	[ROLE_ID] [numeric](38, 0) NOT NULL
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_ONLINE_USER]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_ONLINE_USER]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_ONLINE_USER](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[LOGIN_USERID] [numeric](38, 0) NOT NULL,
	[LOGIN_USERNAME] [nvarchar](50) NOT NULL,
	[LOGIN_IP] [nvarchar](100) NULL,
	[LOGIN_MACHINE] [nvarchar](100) NULL,
	[LOGIN_TIME] [datetime] NOT NULL,
	[SESSION_ID] [nvarchar](100) NULL,
 CONSTRAINT [PK_SYS_ONLINE_USER] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
/****** Object:  Table [dbo].[SYS_NOTICE_TO_USER]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_NOTICE_TO_USER]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_NOTICE_TO_USER](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[NOTICE_ID] [numeric](38, 0) NULL,
	[USER_ID] [numeric](38, 0) NULL,
	[READ_TIME] [datetime] NULL,
	[STATUS] [varchar](50) NULL,
 CONSTRAINT [PK_SYS_NOTICE_TO_USER] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  Table [dbo].[SYS_DESKTOP_TO_USER]    Script Date: 11/12/2012 17:13:22 ******/
SET ANSI_NULLS ON
;
SET QUOTED_IDENTIFIER ON
;
SET ANSI_PADDING ON
;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_USER]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SYS_DESKTOP_TO_USER](
	[ID] [numeric](38, 0) IDENTITY(1,1) NOT NULL,
	[DESKTOP_ID] [numeric](38, 0) NULL,
	[TITLE] [nvarchar](200) NULL,
	[USER_ID] [numeric](38, 0) NULL,
	[LAYOUT_TYPE] [varchar](100) NULL,
	[LAYOUT_VAL] [varchar](2000) NULL,
	[DISPLAY_NUM] [numeric](5, 0) NULL,
	[HEIGHT] [numeric](5, 0) NULL,
	[OPTIONS] [varchar](1000) NULL,
	[FONT_NUM] [numeric](5, 0) NULL,
	[CREATE_USER] [numeric](38, 0) NULL,
	[CREATE_TIME] [datetime] NULL,
	[LAST_UPDATE_USER] [numeric](38, 0) NULL,
	[LAST_UPDATE_TIME] [datetime] NULL,
	[VERSION] [numeric](38, 0) NULL,
	[PARENT_ID] [numeric](38, 0) NULL,
	[STATUS] [varchar](1) NULL,
	[LEVEL_VAL] [numeric](2, 0) NULL,
 CONSTRAINT [PK_SYS_DESKTOP_TO_USER] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
;
SET ANSI_PADDING OFF
;
/****** Object:  ForeignKey [FK__SYS_ATTAC__ATTAC__3DB3258D]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__SYS_ATTAC__ATTAC__3DB3258D]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_ATTACH_DETAIL]'))
ALTER TABLE [dbo].[SYS_ATTACH_DETAIL]  WITH CHECK ADD FOREIGN KEY([ATTACH_ID])
REFERENCES [dbo].[SYS_ATTACH] ([ID])
;
/****** Object:  ForeignKey [FK_SYS_DESK_REFERENCE_SYS_ROLE]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_DESK_REFERENCE_SYS_ROLE]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_DESKTOP_TO_ROLE]  WITH CHECK ADD  CONSTRAINT [FK_SYS_DESK_REFERENCE_SYS_ROLE] FOREIGN KEY([ROLE_ID])
REFERENCES [dbo].[SYS_ROLE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_DESK_REFERENCE_SYS_ROLE]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_DESKTOP_TO_ROLE] CHECK CONSTRAINT [FK_SYS_DESK_REFERENCE_SYS_ROLE]
;
/****** Object:  ForeignKey [FK_SYS_DESK_REFERENCE_SYS_DESK]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_DESK_REFERENCE_SYS_DESK]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_USER]'))
ALTER TABLE [dbo].[SYS_DESKTOP_TO_USER]  WITH CHECK ADD  CONSTRAINT [FK_SYS_DESK_REFERENCE_SYS_DESK] FOREIGN KEY([DESKTOP_ID])
REFERENCES [dbo].[SYS_DESKTOP] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_DESK_REFERENCE_SYS_DESK]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_USER]'))
ALTER TABLE [dbo].[SYS_DESKTOP_TO_USER] CHECK CONSTRAINT [FK_SYS_DESK_REFERENCE_SYS_DESK]
;
/****** Object:  ForeignKey [FK_SYS_DESK_REFERENCE_SYS_USER]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_DESK_REFERENCE_SYS_USER]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_USER]'))
ALTER TABLE [dbo].[SYS_DESKTOP_TO_USER]  WITH CHECK ADD  CONSTRAINT [FK_SYS_DESK_REFERENCE_SYS_USER] FOREIGN KEY([USER_ID])
REFERENCES [dbo].[SYS_USER] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_DESK_REFERENCE_SYS_USER]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DESKTOP_TO_USER]'))
ALTER TABLE [dbo].[SYS_DESKTOP_TO_USER] CHECK CONSTRAINT [FK_SYS_DESK_REFERENCE_SYS_USER]
;
/****** Object:  ForeignKey [FK_SD_DICT_TYPE_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SD_DICT_TYPE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DICTIONARY]'))
ALTER TABLE [dbo].[SYS_DICTIONARY]  WITH CHECK ADD  CONSTRAINT [FK_SD_DICT_TYPE_ID] FOREIGN KEY([DICT_TYPE_ID])
REFERENCES [dbo].[SYS_DICTIONARY_TYPE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SD_DICT_TYPE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_DICTIONARY]'))
ALTER TABLE [dbo].[SYS_DICTIONARY] CHECK CONSTRAINT [FK_SD_DICT_TYPE_ID]
;
/****** Object:  ForeignKey [FK_SYS_NOTI_REFERENCE_SYS_NOTI]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_NOTI_REFERENCE_SYS_NOTI]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_NOTICE_TO_USER]'))
ALTER TABLE [dbo].[SYS_NOTICE_TO_USER]  WITH CHECK ADD  CONSTRAINT [FK_SYS_NOTI_REFERENCE_SYS_NOTI] FOREIGN KEY([NOTICE_ID])
REFERENCES [dbo].[SYS_NOTICE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_NOTI_REFERENCE_SYS_NOTI]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_NOTICE_TO_USER]'))
ALTER TABLE [dbo].[SYS_NOTICE_TO_USER] CHECK CONSTRAINT [FK_SYS_NOTI_REFERENCE_SYS_NOTI]
;
/****** Object:  ForeignKey [FK_SYS_NOTI_REFERENCE_SYS_USER]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_NOTI_REFERENCE_SYS_USER]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_NOTICE_TO_USER]'))
ALTER TABLE [dbo].[SYS_NOTICE_TO_USER]  WITH CHECK ADD  CONSTRAINT [FK_SYS_NOTI_REFERENCE_SYS_USER] FOREIGN KEY([USER_ID])
REFERENCES [dbo].[SYS_USER] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_NOTI_REFERENCE_SYS_USER]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_NOTICE_TO_USER]'))
ALTER TABLE [dbo].[SYS_NOTICE_TO_USER] CHECK CONSTRAINT [FK_SYS_NOTI_REFERENCE_SYS_USER]
;
/****** Object:  ForeignKey [FK_SOU_USER_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SOU_USER_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_ONLINE_USER]'))
ALTER TABLE [dbo].[SYS_ONLINE_USER]  WITH CHECK ADD  CONSTRAINT [FK_SOU_USER_ID] FOREIGN KEY([LOGIN_USERID])
REFERENCES [dbo].[SYS_USER] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SOU_USER_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_ONLINE_USER]'))
ALTER TABLE [dbo].[SYS_ONLINE_USER] CHECK CONSTRAINT [FK_SOU_USER_ID]
;
/****** Object:  ForeignKey [FK_SO_OGR_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SO_OGR_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_ORGANIZATION]'))
ALTER TABLE [dbo].[SYS_ORGANIZATION]  WITH CHECK ADD  CONSTRAINT [FK_SO_OGR_ID] FOREIGN KEY([PARENT_ID])
REFERENCES [dbo].[SYS_ORGANIZATION] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SO_OGR_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_ORGANIZATION]'))
ALTER TABLE [dbo].[SYS_ORGANIZATION] CHECK CONSTRAINT [FK_SO_OGR_ID]
;
/****** Object:  ForeignKey [FK_SR_RESOURCE_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SR_RESOURCE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE]'))
ALTER TABLE [dbo].[SYS_RESOURCE]  WITH CHECK ADD  CONSTRAINT [FK_SR_RESOURCE_ID] FOREIGN KEY([PARENT_ID])
REFERENCES [dbo].[SYS_RESOURCE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SR_RESOURCE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE]'))
ALTER TABLE [dbo].[SYS_RESOURCE] CHECK CONSTRAINT [FK_SR_RESOURCE_ID]
;
/****** Object:  ForeignKey [FK_SRL_RESOURCE_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SRL_RESOURCE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_LOCALE]'))
ALTER TABLE [dbo].[SYS_RESOURCE_LOCALE]  WITH CHECK ADD  CONSTRAINT [FK_SRL_RESOURCE_ID] FOREIGN KEY([RESOURCE_ID])
REFERENCES [dbo].[SYS_RESOURCE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SRL_RESOURCE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_LOCALE]'))
ALTER TABLE [dbo].[SYS_RESOURCE_LOCALE] CHECK CONSTRAINT [FK_SRL_RESOURCE_ID]
;
/****** Object:  ForeignKey [FK_SRTR_RESOURCE_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SRTR_RESOURCE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_RESOURCE_TO_ROLE]  WITH CHECK ADD  CONSTRAINT [FK_SRTR_RESOURCE_ID] FOREIGN KEY([RESOURCE_ID])
REFERENCES [dbo].[SYS_RESOURCE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SRTR_RESOURCE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_RESOURCE_TO_ROLE] CHECK CONSTRAINT [FK_SRTR_RESOURCE_ID]
;
/****** Object:  ForeignKey [FK_SRTR_ROLE_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SRTR_ROLE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_RESOURCE_TO_ROLE]  WITH CHECK ADD  CONSTRAINT [FK_SRTR_ROLE_ID] FOREIGN KEY([ROLE_ID])
REFERENCES [dbo].[SYS_ROLE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SRTR_ROLE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_RESOURCE_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_RESOURCE_TO_ROLE] CHECK CONSTRAINT [FK_SRTR_ROLE_ID]
;
/****** Object:  ForeignKey [FK_SYS_USER_ORG_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_USER_ORG_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_USER]'))
ALTER TABLE [dbo].[SYS_USER]  WITH CHECK ADD  CONSTRAINT [FK_SYS_USER_ORG_ID] FOREIGN KEY([ORGANIZATION_ID])
REFERENCES [dbo].[SYS_ORGANIZATION] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SYS_USER_ORG_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_USER]'))
ALTER TABLE [dbo].[SYS_USER] CHECK CONSTRAINT [FK_SYS_USER_ORG_ID]
;
/****** Object:  ForeignKey [FK_SUTR_ROLE_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SUTR_ROLE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_USER_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_USER_TO_ROLE]  WITH CHECK ADD  CONSTRAINT [FK_SUTR_ROLE_ID] FOREIGN KEY([ROLE_ID])
REFERENCES [dbo].[SYS_ROLE] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SUTR_ROLE_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_USER_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_USER_TO_ROLE] CHECK CONSTRAINT [FK_SUTR_ROLE_ID]
;
/****** Object:  ForeignKey [FK_SUTR_USER_ID]    Script Date: 11/12/2012 17:13:22 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SUTR_USER_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_USER_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_USER_TO_ROLE]  WITH CHECK ADD  CONSTRAINT [FK_SUTR_USER_ID] FOREIGN KEY([USER_ID])
REFERENCES [dbo].[SYS_USER] ([ID])
;
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SUTR_USER_ID]') AND parent_object_id = OBJECT_ID(N'[dbo].[SYS_USER_TO_ROLE]'))
ALTER TABLE [dbo].[SYS_USER_TO_ROLE] CHECK CONSTRAINT [FK_SUTR_USER_ID]
;

CREATE TABLE SYS_DEPLOY_LOG (
   ID                   NUMERIC(38)          IDENTITY(1,1) NOT NULL,
   DEPLOY_URL           NVARCHAR(500)        NULL,
   DEPLOY_VERSION       VARCHAR(100)         NULL,
   DEPLOY_TYPE          NVARCHAR(50)         NULL,
   DEPLOY_NAME          NVARCHAR(100)        NULL,
   DEPLOY_DESC          NVARCHAR(2000)       NULL,
   DEPLOY_TIME_START    DATETIME             NULL,
   DEPLOY_TIME_END      DATETIME             NULL,
   OPERATION_IP         NVARCHAR(100)        NULL,
   OPERATION_MACHINE_NAME NVARCHAR(100)      NULL,
   DEPLOY_FLAG          VARCHAR(50)          NULL,
   EXCEPTION_LOG        NVARCHAR(MAX)        NULL,
   LOGIN_NAME           NVARCHAR(50)         NULL,
   REAL_NAME            NVARCHAR(50)         NULL,
   ORG_NAME             NVARCHAR(100)        NULL,
   ROLLBACK_ID          NUMERIC(38)          NULL,
   CONSTRAINT PK_SYS_DEPLOY_LOG PRIMARY KEY (ID)
)
;

alter table SYS_NOTICE add MODULE_FIELDS nvarchar(2000)
;

/** 2013-02-25 新增任务调度相关表  **/
CREATE TABLE SYS_TASK (
   ID                   NUMERIC(38)          IDENTITY(1,1) NOT NULL,
   CREATE_USER          NUMERIC(38)          NULL,
   CREATE_TIME          DATETIME             NULL,
   LAST_UPDATE_USER     NUMERIC(38)          NULL,
   LAST_UPDATE_TIME     DATETIME             NULL,
   VERSION              NUMERIC(38)          NULL,
   NAME                 NVARCHAR(200)        NULL,
   REMARK               NVARCHAR(500)        NULL,
   TASK_TYPE            VARCHAR(50)          NULL,
   TASK_CONTENT         NVARCHAR(MAX)        NULL,
   CONSTRAINT PK_SYS_TASK PRIMARY KEY (ID)
)
;

CREATE TABLE SYS_TASK_SCHEDULER (
   ID                   NUMERIC(38)          IDENTITY(1,1) NOT NULL,
   CREATE_USER          NUMERIC(38)          NULL,
   CREATE_TIME          DATETIME             NULL,
   LAST_UPDATE_USER     NUMERIC(38)          NULL,
   LAST_UPDATE_TIME     DATETIME             NULL,
   VERSION              NUMERIC(38)          NULL,
   TASK_ID              NUMERIC(38)          NULL,
   NAME                 NVARCHAR(200)        NULL,
   REMARK               NVARCHAR(500)        NULL,
   DATE_TYPE            VARCHAR(50)          NULL,
   RUN_DAY              VARCHAR(50)          NULL,
   RUN_HOUR             VARCHAR(50)          NULL,
   RUN_MINUTE           VARCHAR(50)          NULL,
   RUN_SECOND           VARCHAR(50)          NULL,
   RUN_MONTH            VARCHAR(50)          NULL,
   RUN_WEEK             VARCHAR(50)          NULL,
   STATUS               VARCHAR(50)          NULL,
   CONSTRAINT PK_SYS_TASK_SCHEDULER PRIMARY KEY (ID)
)
;

ALTER TABLE SYS_TASK_SCHEDULER
   ADD CONSTRAINT FK_TS_TASK_ID FOREIGN KEY (TASK_ID)
      REFERENCES SYS_TASK (ID)
;

/** 2013-05-07 新增系统分类功能支持 **/
CREATE TABLE SYS_COMMON_TYPE_TO_ROLE (
   TYPE_ID              NUMERIC(38)        NOT NULL,
   ROLE_ID              NUMERIC(38)        NOT NULL
)
;

ALTER TABLE SYS_COMMON_TYPE_TO_ROLE
   ADD CONSTRAINT FK_SYS_COMM_REFERENCE_SYS_COMM FOREIGN KEY (TYPE_ID)
      REFERENCES SYS_COMMON_TYPE (ID)
;

ALTER TABLE SYS_COMMON_TYPE_TO_ROLE
   ADD CONSTRAINT FK_SYS_COMM_REFERENCE_SYS_ROLE FOREIGN KEY (ROLE_ID)
      REFERENCES SYS_ROLE (ID)
;

alter table SYS_COMMON_TYPE add TYPE_BELONG VARCHAR(2) NULL
;

alter table SYS_COMMON_TYPE add STATUS VARCHAR(1) NULL
;

/** 2013-05-15 新增组织新闻公告关联表 **/
CREATE TABLE SYS_NEWS_TO_ORG (
   NEWS_ID              NUMERIC(38)          NOT NULL,
   ORG_ID               NUMERIC(38)          NOT NULL
)
;

ALTER TABLE SYS_NEWS_TO_ORG
   ADD CONSTRAINT FK_SYS_NEWS_REFERENCE_SYS_NEWS FOREIGN KEY (NEWS_ID)
      REFERENCES SYS_NEWS (ID)
;

ALTER TABLE SYS_NEWS_TO_ORG
   ADD CONSTRAINT FK_SYS_NEWS_REFERENCE_SYS_ORGA FOREIGN KEY (ORG_ID)
      REFERENCES SYS_ORGANIZATION (ID)
;

/** 2013-05-16 角色表新增门户首页地址与登录后首页地址 **/
alter table SYS_ROLE add INDEX_URL VARCHAR(500) NULL
;

alter table SYS_ROLE add PORTAL_URL VARCHAR(500) NULL
;

/** 2013-06-20 数据流转历史记录表 **/
CREATE TABLE SYS_PROCESS_MODEL_INFO (
   ID                   NUMERIC(38)          IDENTITY(1,1) NOT NULL,
   PROCESS_MODEL_ID     NUMERIC(38)          NOT NULL,
   MASTER_ID            NUMERIC(38)          NOT NULL,
   CREATE_USER          NUMERIC(38)          NOT NULL,
   MODEL_KEY            VARCHAR(300)         NOT NULL,
   PROCESS_INSTANCE_ID  VARCHAR(300)         NOT NULL,
   BUSINESS_KEY         VARCHAR(300)         NOT NULL,
   EXECUTION_ID         VARCHAR(300)         NULL,
   CREATE_TIME          DATETIME             NULL,
   CONSTRAINT PK_SYS_PROCESS_MODEL_INFO PRIMARY KEY (ID)
)
;

/** 2013-12-18 用户表增加绑定IP字段，角色可看用户关联表 **/
alter table SYS_USER add BIND_IP VARCHAR(100) NULL
;
CREATE TABLE SYS_ROLE_SEE_USER (
   ROLE_ID              NUMERIC(38)          NULL,
   USER_ID              NUMERIC(38)          NULL
)
;

ALTER TABLE SYS_ROLE_SEE_USER
   ADD CONSTRAINT FK_SYS_ROLE_REFERENCE_SYS_ROLE FOREIGN KEY (ROLE_ID)
      REFERENCES SYS_ROLE (ID)
;

ALTER TABLE SYS_ROLE_SEE_USER
   ADD CONSTRAINT FK_SYS_ROLE_REFERENCE_SYS_USER FOREIGN KEY (USER_ID)
      REFERENCES SYS_USER (ID)
;

/** 2013-12-21 变更日志记录 **/
CREATE TABLE SYS_CHANGE_LOG (
   ID                   NUMERIC(38)          IDENTITY(1,1) NOT NULL,
   MODULE_NAME_EN       VARCHAR(100)         NULL,
   MODULE_NAME_CN       NVARCHAR(100)        NULL,
   TABLE_NAME_EN        VARCHAR(100)         NULL,
   TABLE_NAME_CN        NVARCHAR(100)        NULL,
   FIELD_NAME_EN        VARCHAR(100)         NULL,
   FIELD_NAME_CN        NVARCHAR(100)        NULL,
   ENTITY_NAME          NVARCHAR(200)        NULL,
   ENTITY_ID            VARCHAR(100)         NULL,
   BEFORE_VAL           NVARCHAR(1000)       NULL,
   AFTER_VAL            NVARCHAR(1000)       NULL,
   CHANGE_DESC          NVARCHAR(MAX)        NULL,
   USER_ID              NUMERIC(38)          NULL,
   OPER_TIME            DATETIME             NULL,
   OPER_IP              VARCHAR(100)         NULL,
   LOGIN_NAME           NVARCHAR(100)        NULL,
   REAL_NAME            NVARCHAR(100)        NULL,
   EMPLOYEE_NAME        NVARCHAR(100)        NULL,
   ORG_NAME             NVARCHAR(100)        NULL,
   CONSTRAINT PK_SYS_CHANGE_LOG PRIMARY KEY (ID)
);

/** 2014-04-01 增加邮件发送功能支持  **/
CREATE TABLE SYS_SEND_MAIL_MSG (
   ID                   NUMERIC(38)          IDENTITY(1,1) NOT NULL,
   SENDER               NVARCHAR(200)        NULL,
   SUBJECT              NVARCHAR(500)        NULL,
   MAIL_BODY            NVARCHAR(MAX)        NULL,
   ADDRESSEE            NVARCHAR(MAX)        NULL,
   COPYTO               NVARCHAR(1000)       NULL,
   SEND_TIME            DATETIME             NULL,
   STATUS               VARCHAR(1)           NULL,
   ATM_ID               NUMERIC(38)          NULL,
   SOURCE               VARCHAR(1)           NULL,
   CREATE_TIME          DATETIME             NULL,
   CREATE_USER          NUMERIC(38)          NULL,
   LAST_UPDATE_USER     NUMERIC(38)          NULL,
   LAST_UPDATE_TIME     DATETIME             NULL,
   VERSION              NUMERIC(38)          NULL,
   CONSTRAINT PK_SYS_SEND_MAIL_MSG PRIMARY KEY (ID)
);

/** 2014-04-15 增加短信发送功能支持  **/
CREATE TABLE SYS_SMS_MSG (
   ID                   NUMERIC(38)          IDENTITY,
   CREATE_TIME          DATETIME             NULL,
   CREATE_USER          NUMERIC(38)          NULL,
   LAST_UPDATE_USER     NUMERIC(38)          NULL,
   LAST_UPDATE_TIME     DATETIME             NULL,
   VERSION              NUMERIC(38)          NULL,
   SERVICE_SMS          NVARCHAR(100)        NULL,
   TARGET_PHONE         NVARCHAR(MAX)        NULL,
   SOURCE_PHONE         NVARCHAR(100)        NULL,
   SMS_BODY             NVARCHAR(MAX)        NULL,
   SEND_TIME            DATETIME             NULL,
   STATUS               VARCHAR(1)           NULL,
   REG_SEND_TIME        DATETIME             NULL,
   SOURCE               VARCHAR(1)           NULL,
   RESULT				NVARCHAR(MAX)        NULL,
   CONSTRAINT PK_SYS_SMS_MSG PRIMARY KEY (ID)
);
/* 邮件管理增加服务邮箱号字段 */
ALTER TABLE SYS_SEND_MAIL_MSG ADD SERVICE_MAIL NVARCHAR(100);
ALTER TABLE SYS_SEND_MAIL_MSG ADD RESULT NVARCHAR(MAX);

/** 2014-06-08 增加个人配置表支持快捷方式功能 **/
CREATE TABLE SYS_USER_CONFIG (
   ID                   NUMERIC(38)          IDENTITY,
   USER_ID              NUMERIC(38)          NULL,
   SHORTCUT             NVARCHAR(MAX)        NULL,
   DESK_URL             NVARCHAR(500)        NULL,
   CREATE_TIME          DATETIME             NULL,
   CREATE_USER          NUMERIC(38)          NULL,
   LAST_UPDATE_USER     NUMERIC(38)          NULL,
   LAST_UPDATE_TIME     DATETIME             NULL,
   VERSION              NUMERIC(38)          NULL,
   CONSTRAINT PK_SYS_USER_CONFIG PRIMARY KEY (ID)
);

/** 2014-11-09 增加子实体ID字段 **/
ALTER TABLE SYS_CHANGE_LOG ADD SUB_ENTITY_ID VARCHAR(100);

/** 2015-02-11 邮件增加密送字段 **/
ALTER TABLE SYS_SEND_MAIL_MSG ADD BCC NVARCHAR(1000);

/** yk旧版本到此处 **/

/** 2015-03-10 角色增加可见用户属性字段 **/
ALTER TABLE SYS_ROLE ADD VISIBLE_ATTR VARCHAR(500);

/** 2015-03-11 增加数据共享设置表 **/
CREATE TABLE SYS_DATA_SHARE_CFG (
   ID                   NUMERIC(38)          IDENTITY,
   ENTITY_NAME          NVARCHAR(200)        NULL,
   ENTITY_ID            VARCHAR(100)         NULL,
   OPER_USER_ID         NUMERIC(38)          NULL,
   OPER_TIME            DATETIME             NULL,
   SHARE_USER_ID        NUMERIC(38)          NULL,
   CONSTRAINT PK_SYS_DATA_SHARE_CFG PRIMARY KEY (ID)
);

/** 2015-03-12 增加bbs发帖表 **/
CREATE TABLE SYS_TIE (
  ID NUMERIC(38) NOT NULL IDENTITY,
  CONTENT VARCHAR(MAX),
  PARENT_ID NUMERIC(38) DEFAULT NULL,
  RELEVANCE_ID NUMERIC(38) NOT NULL,
  MODULE_NAME varchar(500) DEFAULT NULL,
  USER_ID NUMERIC(38) NOT NULL,
  TIME DATETIME DEFAULT NULL,
  CONSTRAINT PK_SYS_TIE PRIMARY KEY (ID)
);

/** 2015-04-08 增加备忘录表 **/
CREATE TABLE SYS_MEMO (
   ID                   NUMERIC(38)          IDENTITY,
   CREATE_TIME          DATETIME             NULL,
   CREATE_USER          NUMERIC(38)          NULL,
   LAST_UPDATE_USER     NUMERIC(38)          NULL,
   LAST_UPDATE_TIME     DATETIME             NULL,
   VERSION              NUMERIC(38)          NULL,
   TITLE                NVARCHAR(100)        NULL,
   CONTENT_VAL          NVARCHAR(MAX)        NULL,
   REMIND_TYPE          NVARCHAR(20)         NULL,
   REMIND_TIME          NVARCHAR(10)         NULL,
   REMIND_DATE          DATETIME             NULL,
   REMIND_WEEK          NVARCHAR(100)        NULL,
   STATUS               NVARCHAR(1)          NULL,
   CONSTRAINT PK_SYS_MEMO PRIMARY KEY (ID)
);

/** 2015-04-08 增加备忘录用户关联表 **/
CREATE TABLE SYS_MEMO_TO_USER (
   ID                   NUMERIC(38)          IDENTITY,
   MEMO_ID              NUMERIC(38)          NULL,
   USER_ID              NUMERIC(38)          NULL,
   STATUS               NVARCHAR(1)          NULL,
   CONSTRAINT PK_SYS_MEMO_TO_USER PRIMARY KEY (ID)
);
ALTER TABLE SYS_MEMO_TO_USER
   ADD CONSTRAINT FK_SYS_MEMO_REFERENCE_SYS_MEMO FOREIGN KEY (MEMO_ID)
      REFERENCES SYS_MEMO (ID)
;

/** 2015-04-10 增加访问者关联表 **/
CREATE TABLE SYS_VISITOR (
   ID                   NUMERIC(38)          NOT NULL IDENTITY,
   RELEVANCE_ID         NUMERIC(38)          NULL,
   USER_ID              NUMERIC(38)          NULL,
   VISIT_TIME           DATETIME             NULL,
   CONSTRAINT PK_SYS_VISITOR PRIMARY KEY (ID)
);

/** 2015-05-25 增加签到表 **/
CREATE TABLE SYS_CHECKINS (
   ID                   NUMERIC(38)          NOT NULL IDENTITY,
   CHECHINS_TIME        DATETIME             NULL,
   LNG                  NUMERIC(9,6)         NULL,
   LAT                  NUMERIC(9,6)         NULL,
   USER_ID              NUMERIC(38)          NULL,
   TITLE                NVARCHAR(100)         NULL,
   CONTENT              NVARCHAR(1000)        NULL,
   PALCE                NVARCHAR(100)         NULL,
   ATTACH_CONTENT         NVARCHAR(MAX)        NULL,
   TYPE					VARCHAR(2)			NULL,
   CONSTRAINT PK_SYS_CHECKINS PRIMARY KEY (ID)
);

/** 2016-03-29 无主键表增加联合主键 **/
ALTER TABLE sys_common_type_to_role ADD CONSTRAINT PK_SYS_CT_TO_ROLE PRIMARY KEY(TYPE_ID, ROLE_ID);
ALTER TABLE sys_desktop_to_role ADD CONSTRAINT PK_SYS_DESKTOP_TO_ROLE PRIMARY KEY(DESKTOP_ID, ROLE_ID);
ALTER TABLE sys_news_to_org ADD CONSTRAINT PK_SYS_NEWS_TO_ORG PRIMARY KEY(NEWS_ID, ORG_ID);
ALTER TABLE sys_resource_to_role ADD CONSTRAINT PK_SYS_RESOURCE_TO_ROLE PRIMARY KEY(RESOURCE_ID, ROLE_ID);
ALTER TABLE sys_user_to_role ADD CONSTRAINT PK_SYS_USER_TO_ROLE PRIMARY KEY(USER_ID, ROLE_ID);

alter table sys_role_see_user NOCHECK constraint all;
ALTER TABLE sys_role_see_user ADD CONSTRAINT PK_SYS_ROLE_SEE_USER PRIMARY KEY(ROLE_ID, USER_ID);
alter table sys_role_see_user CHECK constraint all;

/** 2016-10-13 增加用户自定义字段相关表 **/
CREATE TABLE SYS_BS_TABLE (
   ID                 NUMERIC(38)          NOT NULL IDENTITY,
   SYSTEM_CODE        VARCHAR(100)             NULL,
   TABLE_KEY          VARCHAR(200)         NULL,
   ENTITY_NAME 		  VARCHAR(400)			NULL,
   CAPTION			  NVARCHAR(200)			NULL,
   REMARK       NVARCHAR(1000)			NULL,
   ALLOW_USER_DEF_FIELD       VARCHAR(100)			NULL,
   STATUS       VARCHAR(100)			NULL,
   CREATE_USER NUMERIC(38) NULL,
   CREATE_TIME datetime NULL,
   LAST_UPDATE_USER NUMERIC(38) NULL,
   LAST_UPDATE_TIME datetime NULL,
   VERSION NUMERIC(38) NULL,
   CONSTRAINT PK_SYS_BS_TABLE PRIMARY KEY (ID)
);

CREATE TABLE SYS_BS_FIELD (
   ID                 NUMERIC(38)          NOT NULL IDENTITY,
   MASTER_ID	NUMERIC(38),
   TABLE_KEY          VARCHAR(200)         NULL,
   ENTITY_NAME 		  VARCHAR(400)			NULL,
   FIELD_KEY          VARCHAR(200)         NULL,
   CAPTION			  NVARCHAR(200)			NULL,
   REMARK       NVARCHAR(1000)			NULL,
   DATA_TYPE       VARCHAR(100)			NULL,
   EDIT_TYPE       VARCHAR(100)			NULL,
   STATUS       VARCHAR(100)			NULL,
   EDIT_DS       NVARCHAR(MAX) 			NULL,
   FORMAT       NVARCHAR(100)			NULL,
   EXP_RULE       NVARCHAR(1000)			NULL,
   DEFAULT_VAL     NVARCHAR(200)			NULL,
   FIELD_TYPE       VARCHAR(100)			NULL,
   CREATE_USER NUMERIC(38) NULL,
   CREATE_TIME datetime NULL,
   LAST_UPDATE_USER NUMERIC(38) NULL,
   LAST_UPDATE_TIME datetime NULL,
   VERSION NUMERIC(38) NULL,
   CONSTRAINT PK_SYS_BS_FIELD PRIMARY KEY (ID)
);

CREATE TABLE SYS_BS_FIELD_INS (
   ID                 NUMERIC(38)          NOT NULL IDENTITY,
   MASTER_ID	NUMERIC(38),
   TABLE_KEY          VARCHAR(200)         NULL,
   ENTITY_NAME 		  VARCHAR(400)			NULL,
   ENTITY_ID		  VARCHAR(100)			NULL,
   FIELD_KEY          VARCHAR(200)         NULL,
   CAPTION			  NVARCHAR(200)			NULL,
   DATA_TYPE       VARCHAR(100)			NULL,
   EDIT_TYPE       VARCHAR(100)			NULL,
   STATUS       VARCHAR(100)			NULL,
   STRING_VAL       NVARCHAR(4000)			NULL,
   LONG_VAL       NUMERIC(38)			NULL,
   DOUBLE_VAL     NUMERIC(30,8)		NULL,
   TEXT_VAL       NVARCHAR(MAX) 	NULL,
   DATE_VAL datetime NULL,
   CREATE_USER NUMERIC(38) NULL,
   CREATE_TIME datetime NULL,
   LAST_UPDATE_USER NUMERIC(38) NULL,
   LAST_UPDATE_TIME datetime NULL,
   VERSION NUMERIC(38) NULL,
   CONSTRAINT PK_SYS_BS_FIELD_INS PRIMARY KEY (ID)
);

/* 2016-12-15 用户表增加头像和签名字段  */
ALTER TABLE SYS_USER ADD  AVATAR NVARCHAR(1000);
ALTER TABLE SYS_USER ADD  SIGNATURE NVARCHAR(200);
ALTER TABLE SYS_USER ADD  UID NVARCHAR(100);

/* 2017-01-22 业务表增加模块key和主实体名  */
ALTER TABLE SYS_BS_TABLE ADD  MODULE_KEY VARCHAR(200);
ALTER TABLE SYS_BS_TABLE ADD  MASTER_ENTITY_NAME VARCHAR(400);
ALTER TABLE SYS_BS_FIELD ADD  MODULE_KEY VARCHAR(200);
ALTER TABLE SYS_BS_FIELD ADD  FIELD_INDEX VARCHAR(100);
ALTER TABLE SYS_BS_FIELD ADD  IS_TEXT_FIELD VARCHAR(10);

/* 2017-04-15 增加业务模块表 */
CREATE TABLE SYS_BS_MODULE (
   ID                 NUMERIC(38)          NOT NULL IDENTITY,
   CAPTION			  NVARCHAR(200)			NULL,
   REMARK       NVARCHAR(1000)			NULL,
   STATUS       VARCHAR(100)			NULL,
   MODULE_KEY	VARCHAR(200) NULL,
   REF_MODULE_KEY	VARCHAR(200) NULL,
   MODULE_TYPE	VARCHAR(100) NULL,
   CREATE_USER NUMERIC(38) NULL,
   CREATE_TIME datetime NULL,
   LAST_UPDATE_USER NUMERIC(38) NULL,
   LAST_UPDATE_TIME datetime NULL,
   VERSION NUMERIC(38) NULL,
   CONSTRAINT PK_SYS_BS_MODULE PRIMARY KEY (ID)
);

/* 2018-07-09 增加分类排序号 */
alter table SYS_COMMON_TYPE add  SORT_ORDER_NO VARCHAR(10) NULL;

/* 2018-09-01  添加菜单资源表的模块展示类型*/
alter table SYS_RESOURCE add  APP_SHOW TINYINT(1) DEFAULT 0;